// ============================================================================
// Name : BaseInfo.java
// Author : iron.yin@gmail.com
// Version : v1.0
// Copyright : RisingSun CO,.LTD
// Description : BaseInfo.java in Java
// ============================================================================
package cc.risingsun.wing.core;

import java.lang.annotation.Annotation;
import java.util.Map;
import java.util.Set;

import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;

import cc.risingsun.wing.ds.DataStruct;

/**
 * 
 * @author iron.yin@gmail.com
 * @sina 2012-7-19
 */
public abstract class WingBase implements Opcodes {

	protected Type owner;
	private String name;
	//protected Type ownerType, selfType;
	protected Map<Class<? extends Annotation>, WingAnnotation> annotaions;
	
	protected Set<Annotation> annos;
	
	WingBase(String owner, String name) {
		this.owner = Type.getType(owner);
		this.name = name;
		
		//ownerType = Type.getType(owner);
		//selfType = Type.getType(name);
		annotaions = DataStruct.hashMap();
		annos = DataStruct.hashSet();
	}
	
	public String getName(){
		return name;
	}

	void addAnnotation(Class<? extends Annotation> clazz,WingAnnotation annotation) {
		annotaions.put(clazz, annotation);
	}

	/**
	 * @return the specified annotaion
	 */
	public WingAnnotation getAnnotaion(Class<?> clazz) {
		return annotaions.get(clazz);
	}
	
	public Map<Class<? extends Annotation>, WingAnnotation> getAnnotations(){
		return annotaions;
	}
	
	WingAnnotation createAnnotation(String owner, String name,Class<? extends Annotation> clazz) {
		final WingAnnotation annotation = new WingAnnotation(owner, name);
		addAnnotation(clazz,annotation);
		return annotation;
	}
}
